<template>
  <div class="pubBig standard BedinformationMZPB">
    <div class="h0">
      <p class="lt"></p>
    </div>
    <div class="dRightMain">
      <div
        style="height: 80%"
        class="cardP"
      >
        <el-card class="box-card">
          <div
            slot="header"
            class="clearfix"
          >
            <span>排班信息</span>
            <el-button
              style="float: right; "
              type="success"
              @click="showDialogYS('XZPB')"
            >新增排班
            </el-button>
          </div>
          <div>
            <el-row>

              <el-col :span="6">
                <div class="grid-content bg-purple div_P">
                  <div class="form-group">
                    <p>
                      <label>医院：</label>
                      <select
                        class="form-control"
                        v-model="selectZZJGObj"
                        @change="getDeptListYS()"
                        placeholder="请选择"
                      >
                        <option
                          v-for="(item,index) in zzjgList"
                          :label="item.HospitalName"
                          :value="item"
                          :key="index"
                        ></option>
                      </select>
                    </p>

                  </div>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple div_P">
                  <div class="form-group">
                    <p>
                      <label>科室：</label>
                      <select
                        class="form-control"
                        v-model="selectDeptYS"
                        @change="getUserList"
                        placeholder="请选择"
                      >
                        <option
                          v-for="(item,index) in deptListYS"
                          :label="item.Name"
                          :value="item"
                          :key="index"
                        ></option>
                      </select>
                    </p>
                  </div>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple div_P">
                  <div class="form-group">
                    <p>
                      <label>医生</label>
                      <select
                        class="form-control"
                        v-model="selectDoctor"
                        placeholder="请选择"
                      >
                        <option
                          v-for="(item,index) in userList"
                          :label="item.UserName"
                          :value="item"
                          :key="index"
                        ></option>
                      </select>
                    </p>
                  </div>
                </div>
              </el-col>
              <el-col :span="6">
                <div class="grid-content bg-purple div_P">
                  <div class="form-group">
                    <p>
                      <el-button
                        type="primary"
                        @click="getSZTime()"
                      >上周</el-button>
                      <el-button
                        type="primary"
                        @click="getBZTime()"
                      >本周</el-button>
                      <el-button
                        type="primary"
                        @click="getXZTime()"
                      >下周</el-button>
                    </p>
                  </div>
                </div>
              </el-col>
            </el-row>
          </div>
        </el-card>

        <el-table
          :data="tableData"
          style="width: 100%"
        >
          <el-table-column
            fixed="left"
            label="姓名"
            width="120"
          >
            <template slot-scope="scope">
              <el-tag type="success">{{scope.row.name}}</el-tag>

            </template>
          </el-table-column>
          <el-table-column :label="Date1">
            <el-table-column
              label="上午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success">{{scope.row.Data1.SW.count}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              label="下午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success"> {{scope.row.Data1.XW.count}}</el-tag>
              </template>
            </el-table-column>

          </el-table-column>
          <el-table-column :label="Date2">
            <el-table-column
              label="上午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success">{{scope.row.Data2.SW.count}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              label="下午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success"> {{scope.row.Data2.XW.count}}</el-tag>
              </template>
            </el-table-column>

          </el-table-column>
          <el-table-column :label="Date3">
            <el-table-column
              label="上午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success">{{scope.row.Data3.SW.count}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              label="下午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success"> {{scope.row.Data3.XW.count}}</el-tag>
              </template>
            </el-table-column>

          </el-table-column>
          <el-table-column :label="Date4">
            <el-table-column
              label="上午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success">{{scope.row.Data4.SW.count}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              label="下午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success"> {{scope.row.Data4.XW.count}}</el-tag>
              </template>
            </el-table-column>

          </el-table-column>
          <el-table-column :label="Date5">
            <el-table-column
              label="上午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success">{{scope.row.Data5.SW.count}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              label="下午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success"> {{scope.row.Data5.XW.count}}</el-tag>
              </template>
            </el-table-column>

          </el-table-column>
          <el-table-column :label="Date6">
            <el-table-column
              label="上午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success">{{scope.row.Data6.SW.count}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              label="下午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success"> {{scope.row.Data6.XW.count}}</el-tag>
              </template>
            </el-table-column>

          </el-table-column>
          <el-table-column :label="Date7">
            <el-table-column
              label="上午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success">{{scope.row.Data7.SW.count}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              label="下午"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag type="success"> {{scope.row.Data7.XW.count}}</el-tag>
              </template>
            </el-table-column>

          </el-table-column>

        </el-table>

        <el-button
          raw-type="button"
          @click="addCol"
          v-if="false"
        >
          添加一列
        </el-button>

      </div>
    </div>
    <!--弹框添加排班-->
    <div
      class="blackBg hyCZBg"
      v-if="isShowYS=='XZPB'"
    >
      <div class="panel-default column2">
        <em
          class="closes"
          @click="showDialogYS('')"
        >×</em>
        <div class="panel-heading">新增排班</div>
        <div class="pucLabel">
          <el-row>

            <el-col :span="8">
              <div class="grid-content bg-purple div_P">
                <div class="form-group">
                  <p>
                    <label>医院：</label>
                    <select
                      class="form-control"
                      v-model="selectZZJGObjXZ"
                      @change="getDeptListYS()"
                      placeholder="请选择"
                    >
                      <option
                        v-for="(item,index) in zzjgList"
                        :label="item.HospitalName"
                        :value="item"
                        :key="index"
                      ></option>
                    </select>
                  </p>

                </div>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple div_P">
                <div class="form-group">
                  <p>
                    <label>科室：</label>
                    <select
                      class="form-control"
                      v-model="selectDeptYSXZ"
                      @change="getUserListXZ"
                      placeholder="请选择"
                    >
                      <option
                        v-for="(item,index) in deptListYS"
                        :label="item.Name"
                        :value="item"
                        :key="index"
                      ></option>
                    </select>
                  </p>
                </div>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple div_P">
                <div class="form-group">
                  <p>
                    <label>医生</label>
                    <select
                      class="form-control"
                      v-model="selectDoctorXZ"
                      placeholder="请选择"
                    >
                      <option
                        v-for="(item,index) in userListXZ"
                        :label="item.UserName"
                        :value="item"
                        :key="index"
                      ></option>
                    </select>
                  </p>
                </div>
              </div>
            </el-col>

          </el-row>
          <el-row>

            <el-col :span="8">
              <div class="grid-content bg-purple div_P">
                <div class="form-group">
                  <p class="selectTime">
                    <label>起止时间：</label>
                    <el-date-picker
                      style="width: 10rem;height:32px"
                      type="date"
                      value-format="yyyy-MM-dd"
                      v-model="addHZPB.BeginScheduleDate"
                      placeholder="选择日期"
                    >
                    </el-date-picker>
                    -
                    <el-date-picker
                      style="width:10rem;height:32px"
                      type="date"
                      value-format="yyyy-MM-dd"
                      v-model="addHZPB.EndScheduleDate"
                      placeholder="选择日期"
                    >
                    </el-date-picker>
                  </p>

                </div>
              </div>
            </el-col>
            <el-col :span="16">
              <div class="grid-content bg-purple div_P">
                <div class="form-group">
                  <p>
                    <label>出诊频率：</label>
                    <el-checkbox
                      :indeterminate="isIndeterminate"
                      v-model="checkAll"
                      @change="handleCheckAllChange"
                    >全选
                    </el-checkbox>

                    <el-checkbox-group
                      v-model="checkedCities"
                      @change="handleCheckedCitiesChange"
                    >
                      <el-checkbox
                        v-for="city in cities"
                        :label="city"
                        :key="city"
                      >{{city}}
                      </el-checkbox>
                    </el-checkbox-group>

                  </p>
                </div>
              </div>
            </el-col>
          </el-row>
          <el-row>

            <el-col :span="8">
              <div class="grid-content bg-purple div_P">
                <div class="form-group">
                  <p>
                    <label>接诊时长：</label>
                    <select
                      class="form-control"
                      v-model="addHZPB.IntervalMinute"
                      @change="getDeptListYS()"
                      placeholder="请选择"
                    >
                      <option
                        v-for="(item,index) in JZSC"
                        :label="item.name"
                        :value="item.value"
                        :key="index"
                      ></option>
                    </select>
                  </p>
                </div>
              </div>
            </el-col>

          </el-row>
          <el-row>

            <el-col :span="24">
              <div class="grid-content bg-purple div_P">
                <div class="form-group">
                  <p
                    class="selectTime but"
                    v-for="(item,i) in addHZPB.TimeLst"
                  >
                    <label>接诊时间：</label>
                    <el-time-select
                      style="width:10rem;height:32px"
                      v-model="item.Stime"
                      :picker-options="{    start: '07:30',    step: '00:15',    end: '19:30'  }"
                      placeholder="选择时间"
                    >
                    </el-time-select>
                    -
                    <el-time-select
                      style="width:10rem;height:32px"
                      v-model="item.ETime"
                      :picker-options="{    start: '07:30',    step: '00:15',    end: '19:30'  }"
                      placeholder="选择时间"
                    >
                    </el-time-select>
                    <el-button
                      type="danger"
                      icon="el-icon-close"
                      circle
                      @click="DialogremoveTime(i)"
                    ></el-button>
                  </p>
                  <p class="selectTime but">
                    <el-button
                      type="primary"
                      icon="el-icon-plus"
                      circle
                      @click="DialogAddTime()"
                    ></el-button>
                  </p>
                </div>
              </div>
            </el-col>

          </el-row>
        </div>
        <div class="modal-footer">
          <button
            type="button"
            class="btn btn-default"
            @click="addHZPB2Http()"
          >确定</button>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
const cityOptions = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'];
export default {
  name: "BedinformationFZ",
  data () {
    return {
      msg: "SystemManagement 下的 Bedinformation",
      isShow: "",
      isShowYS: "",
      /*****************************会诊医生排班*************************************/
      zzjgList: [],
      deptList: [],
      LoginInfor: {},
      deptListYS: [],
      userList: [],
      selectDoctor: {},
      selectDept: {},
      selectDeptYS: {},
      selectZZJGObj: {},
      Date1: "2020-02-09",
      Date2: "2020-02-09",
      Date3: "2020-02-09",
      Date4: "2020-02-09",
      Date5: "2020-02-09",
      Date6: "2020-02-09",
      Date7: "2020-02-09",
      tableData: [],
      tableData222: [
        {
          name: "张珊",
          Data1: {
            Time: "星期一",
            SW: "15",
            XW: "10"
          },
          Data2: {
            Time: "星期二",
            SW: "15",
            XW: "10"
          },
          Data3: {
            Time: "星期三",
            SW: "15",
            XW: "10"
          },
          Data4: {
            Time: "星期四",
            SW: "15",
            XW: "10"
          },
          Data5: {
            Time: "星期五",
            SW: "15",
            XW: "10"
          },
          Data6: {
            Time: "星期六",
            SW: "15",
            XW: "10"
          },
          Data7: {
            Time: "星期日",
            SW: "15",
            XW: "10"
          },

        }, {
          name: "王娜",
          Data1: {
            Time: "星期一",
            SW: "15",
            XW: "10"
          },
          Data2: {
            Time: "星期二",
            SW: "15",
            XW: "10"
          },
          Data3: {
            Time: "星期三",
            SW: "15",
            XW: "10"
          },
          Data4: {
            Time: "星期四",
            SW: "15",
            XW: "10"
          },
          Data5: {
            Time: "星期五",
            SW: "15",
            XW: "10"
          },
          Data6: {
            Time: "星期六",
            SW: "15",
            XW: "10"
          },
          Data7: {
            Time: "星期日",
            SW: "15",
            XW: "10"
          },

        }],
      tableData2:
        [

        ],
      tableData22:
        [
          {
            name: "张珊",
            timeList: [
              { time: "2020-02-03", SW: 1, XW: 11 },
              { time: "2020-04", SW: 2, XW: 10 },
              { time: "2020-05", SW: 3, XW: 10 },
              { time: "2020-02-06", SW: 4, XW: 10 },
              { time: "2020-07", SW: 5, XW: 10 },
              { time: "2020-08", SW: 6, XW: 10 },
              { time: "2020-09", SW: 7, XW: 10 },
            ]
          },
          {
            name: "王珊",
            timeList: [
              { time: "2020-03", SW: 12, XW: 10 },
              { time: "2020-04", SW: 12, XW: 10 },
              { time: "2020-05", SW: 12, XW: 10 },
              { time: "2020-06", SW: 12, XW: 10 },
              { time: "2020-07", SW: 12, XW: 10 },
              { time: "2020-09", SW: 12, XW: 10 },
            ]
          },
        ],
      cols:
        [
          // {prop: 'date', label: '日期'},
        ],
      /***新增排班**/
      selectDoctorXZ:
        {}
      ,
      selectDeptXZ: {}
      ,
      selectDeptYSXZ: {}
      ,
      selectZZJGObjXZ: {}
      ,
      userListXZ: [],
      Time:
        "",
      JZSC:
        [{ name: "15分钟", value: 15 }, { name: "30分钟", value: 30 }],
      addHZPB:
      {
        Id: 0,
        HospitalId:
          0,
        DeptId:
          0,
        DoctorId:
          0,
        ConsultRoomId:
          0,
        BeginScheduleDate:
          "2020-02-05T03:54:24.709Z",
        EndScheduleDate:
          "2020-02-05T03:54:24.709Z",
        WeekList:
          "",
        IntervalMinute:
          0,
        TimeList:
          "string",
        TimeLst:
          [{ Stime: "", ETime: "" }]

      }
      ,
      getHZPBObj: {
        bdate: "",
        edate:
          "",
        HospitalId:
          "-1",
        DeptId:
          "-1",
        DoctorId:
          "-1",
      }
      ,
      /***周**/
      checkAll: false,
      checkedCities:
        [],
      cities:
        cityOptions,
      isIndeterminate:
        true
    }
      ;
  },
  methods: {
    showDialog (show) {
      this.isShow = show;
      if (show == "") {
        this.selectHZInfor = null;
        // this.isShowYS = "";
      }
    },
    showDialogYS (show) {
      this.isShowYS = show;
    },

    /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&会诊医生排班开始&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
    getZZJGList () {
      this.zzjgList = [];
      var params = {
        name: ""
      };
      this.$get("Hospital/GetList", params)
        .then(res => {
          //this.total = res.data.totalCount;//
          this.zzjgList = res.data;
          if (this.zzjgList.length > 0) {
            this.selectZZJGObj = this.zzjgList[0];
            this.getDeptListYS();
          }
          console.log("组织机构列表查询结果");
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    },
    getDeptListYS () {
      //
      var params = {
        HospitalId: this.selectZZJGObj.HospitalId,
        name: ""
      };
      this.$get("Dept/GetList", params)
        .then(res => {
          this.deptListYS = res.data;
          console.log("科室列表查询结果");
          console.log(res);
          if (this.deptListYS.length > 0) {
            this.selectDeptYS = this.deptListYS[0];
            this.getBZTime();
          }

        })
        .catch(err => {
          console.log(err);
        });
    },
    getUserList () {
      this.userList = [];

      if (this.selectZZJGObj == null) {
        this.$message({
          showClose: true,
          message: "请选择操作机构！",
          type: "error"
        });
        return;
      }
      var params = {
        HospitalId: this.selectZZJGObj.HospitalId,
        SectionId: this.selectDeptYS.Id
      };
      this.$get("User/GetListBySection", params)
        .then(res => {
          this.userList = res.data;
          console.log("用户列表查询结果");
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    },
    getUserListXZ () {
      this.userListXZ = [];

      if (this.selectZZJGObjXZ == null) {
        this.$message({
          showClose: true,
          message: "请选择操作机构！",
          type: "error"
        });
        return;
      }
      var params = {
        HospitalId: this.selectZZJGObjXZ.HospitalId,
        SectionId: this.selectDeptYSXZ.Id
      };
      this.$get("User/GetListBySection", params)
        .then(res => {
          this.userListXZ = res.data;
          console.log("用户列表查询结果");
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    },
    addCol () {
      for (var i = 0; i < this.tableData.length; i++) {
        for (var j = 0; j < this.tableData[i].timeList.length; j++) {
          var timeName = this.tableData[i].timeList[j].time
          var count = this.tableData[i].timeList[j].count
          var vars = {}; //批量定义
          var varName = timeName;  //动态定义变量名
          this.tableData[i][varName] = count;  //动态赋值
        }
      }
      console.log("排班数据调整完成");
      console.log(this.tableData);
      for (var j = 0; j < this.tableData[0].timeList.length; j++) {
        var timeName = this.tableData[0].timeList[j].time
        this.setCol(timeName)
      }
    },
    setCol (label) {
      this.cols.push({ prop: label, label: label })
    },
    DialogAddTime () {
      var Time = {
        Stime: "", ETime: ""
      }
      this.addHZPB.TimeLst.push(Time);
    },
    DialogremoveTime (index) {

      this.addHZPB.TimeLst.splice(index, 1);
    },
    addHZPB2Http () {
      if (this.selectDoctorXZ == null) {
        this.$message({
          showClose: true,
          message: "请选择医生！",
          type: "error"
        });
        return;
      }
      this.addHZPB.HospitalId = this.selectZZJGObjXZ.HospitalId;
      this.addHZPB.DeptId = this.selectDeptYSXZ.Id;
      this.addHZPB.DoctorId = this.selectDoctorXZ.UserId;
      var TimeStr = '';
      for (var i = 0; i < this.addHZPB.TimeLst.length; i++) {
        if (i == (this.addHZPB.TimeLst.length - 1)) {
          TimeStr += this.addHZPB.TimeLst[i].Stime + '^' + this.addHZPB.TimeLst[i].ETime;
        } else {
          TimeStr += this.addHZPB.TimeLst[i].Stime + '^' + this.addHZPB.TimeLst[i].ETime + '#';
        }
      }
      console.log("时间段拼接")
      console.log(TimeStr);

      this.addHZPB.TimeList = TimeStr;
      var weekStr = this.checkedCities.toLocaleString();
      console.log(weekStr)
      this.addHZPB.WeekList = weekStr;
      this.addHZPB.TimeLst = [];
      this.addHZPB.BeginScheduleDate = this.addHZPB.BeginScheduleDate + " 00:00:00";
      this.addHZPB.EndScheduleDate = this.addHZPB.EndScheduleDate + " 00:00:00"

      var params = this.addHZPB;
      //POST /api/OutPatientScheduling/addScheduleList
      this.$post("OutPatientScheduling/addScheduleList", params)
        .then(res => {
          console.log("添加专家排班结果");
          console.log(res);
          if (res.code == 0) {
            this.addHZPB = {
              Id: 0,
              HospitalId: 0,
              DeptId: 0,
              DoctorId: 0,
              ConsultRoomId: 0,
              BeginScheduleDate: "2020-02-05T03:54:24.709Z",
              EndScheduleDate: "2020-02-05T03:54:24.709Z",
              WeekList: "",
              IntervalMinute: 0,
              TimeList: "string",
              TimeLst: [{ Stime: "", ETime: "" }]

            }
            this.showDialog("");
          } else {
            this.$message({
              showClose: true,
              message: res.msg,
              type: "error"
            });
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    handleCheckAllChange (val) {
      this.checkedCities = val ? cityOptions : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange (value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.cities.length;
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
    },


    /*****获取排班信息*******/
    getHZPBList (bdate, edate) {
      if (this.selectDeptYS == null) {
        this.$message({
          showClose: true,
          message: "请选择科室！",
          type: "error"
        });
        return;
      }
      this.getHZPBObj.HospitalId = this.selectZZJGObj.HospitalId;
      this.getHZPBObj.DeptId = this.selectDeptYS.Id;
      if (this.selectDoctor != null && this.selectDoctor.UserId != null && this.selectDoctor.UserId != "") {
        this.getHZPBObj.DoctorId = this.selectDoctor.UserId;
      }
      this.getHZPBObj.bdate = bdate
      this.getHZPBObj.edate = edate;
      var params = this.getHZPBObj;
      // GET /api/OutPatientScheduling/GetList
      this.$get("OutPatientScheduling/GetList", params)
        .then(res => {
          console.log("门诊排班列表查询结果");
          console.log(res);
          this.tableData2 = res.data;
          this.tableData = [];
          for (var i = 0; i < this.Date1.toString().indexOf('-0'); i++) {
            this.Date1 = this.Date1.toString().replace("-0", '/')
            this.Date2 = this.Date2.toString().replace("-0", '/')
            this.Date3 = this.Date3.toString().replace("-0", '/')
            this.Date4 = this.Date4.toString().replace("-0", '/')
            this.Date5 = this.Date5.toString().replace("-0", '/')
            this.Date6 = this.Date6.toString().replace("-0", '/')
            this.Date7 = this.Date7.toString().replace("-0", '/')
          }
          for (var i = 0; i < this.Date1.toString().indexOf('-'); i++) {
            this.Date1 = this.Date1.toString().replace("-", '/')
            this.Date2 = this.Date2.toString().replace("-", '/')
            this.Date3 = this.Date3.toString().replace("-", '/')
            this.Date4 = this.Date4.toString().replace("-", '/')
            this.Date5 = this.Date5.toString().replace("-", '/')
            this.Date6 = this.Date6.toString().replace("-", '/')
            this.Date7 = this.Date7.toString().replace("-", '/')
          }
          for (var i = 0; i < this.tableData2.length; i++) {
            var itemObj = {
              name: this.tableData2[i].DoctorName,
              DeptId: this.tableData2[i].DeptId,
              DeptName: this.tableData2[i].DeptName,
              DoctorId: this.tableData2[i].DoctorId,
              DoctorName: this.tableData2[i].DoctorName,
              HospitalId: this.tableData2[i].HospitalId,
              HospitalName: this.tableData2[i].HospitalName,
              Data1: { SW: { count: 0, Id: '' }, XW: { count: 0, Id: '' } },
              Data2: { SW: { count: 0, Id: '' }, XW: { count: 0, Id: '' } },
              Data3: { SW: { count: 0, Id: '' }, XW: { count: 0, Id: '' } },
              Data4: { SW: { count: 0, Id: '' }, XW: { count: 0, Id: '' } },
              Data5: { SW: { count: 0, Id: '' }, XW: { count: 0, Id: '' } },
              Data6: { SW: { count: 0, Id: '' }, XW: { count: 0, Id: '' } },
              Data7: { SW: { count: 0, Id: '' }, XW: { count: 0, Id: '' } },
            }
            for (var j = 0; j < this.tableData2[i].DateList.length; j++) {
              // console.log("日期对照")
              // console.log(this.tableData2[i].DateList[j].ScheduleDate)
              // console.log("日期对照第一天")
              // console.log(this.Date1+" 0:00:00")
              if (this.tableData2[i].DateList[j].ScheduleDate == this.Date1 + " 0:00:00") {
                // itemObj.Data1.SW = this.tableData2[i].timeList[j].SW;
                // itemObj.Data1.XW = this.tableData2[i].timeList[j].XW;
                // console.log("日期对照成功")
                // console.log(this.Date1+" 0:00:00")
                for (var n = 0; n < this.tableData2[i].DateList[j].MorningList.length; n++) {
                  console.log("第一天上午")
                  console.log(this.tableData2[i].DateList[j].MorningList[n])
                  itemObj.Data1.SW.count += this.tableData2[i].DateList[j].MorningList[n].Total
                  itemObj.Data1.SW.Id = this.tableData2[i].DateList[j].MorningList[n].Id
                }
                for (var n = 0; n < this.tableData2[i].DateList[j].AfterNoonList.length; n++) {
                  console.log("第一天下午")
                  console.log(this.tableData2[i].DateList[j].AfterNoonList[n])
                  itemObj.Data1.XW.count += this.tableData2[i].DateList[j].AfterNoonList[n].Total
                  itemObj.Data1.XW.Id = this.tableData2[i].DateList[j].AfterNoonList[n].Id
                }
              }
              else if (this.tableData2[i].DateList[j].ScheduleDate === this.Date2 + " 0:00:00") {
                for (var n = 0; n < this.tableData2[i].DateList[j].MorningList.length; n++) {
                  itemObj.Data2.SW.count += this.tableData2[i].DateList[j].MorningList[n].Total
                  itemObj.Data2.SW.Id = this.tableData2[i].DateList[j].MorningList[n].Id
                }
                for (var n = 0; n < this.tableData2[i].DateList[j].AfterNoonList.length; n++) {
                  itemObj.Data2.XW.count += this.tableData2[i].DateList[j].AfterNoonList[n].Total
                  itemObj.Data2.XW.Id = this.tableData2[i].DateList[j].AfterNoonList[n].Id
                }
              }
              else if (this.tableData2[i].DateList[j].ScheduleDate === this.Date3 + " 0:00:00") {
                console.log("比对成功")
                console.log(this.tableData2[i].DateList[j].MorningList.length)
                for (var n = 0; n < this.tableData2[i].DateList[j].MorningList.length; n++) {
                  itemObj.Data3.SW.count += this.tableData2[i].DateList[j].MorningList[n].Total
                  itemObj.Data3.SW.Id = this.tableData2[i].DateList[j].MorningList[n].Id
                }
                for (var n = 0; n < this.tableData2[i].DateList[j].AfterNoonList.length; n++) {
                  itemObj.Data3.XW.count += this.tableData2[i].DateList[j].AfterNoonList[n].Total
                  itemObj.Data3.XW.Id = this.tableData2[i].DateList[j].AfterNoonList[n].Id
                }
              }
              else if (this.tableData2[i].DateList[j].ScheduleDate === this.Date4 + " 0:00:00") {
                for (var n = 0; n < this.tableData2[i].DateList[j].MorningList.length; n++) {
                  itemObj.Data4.SW.count += this.tableData2[i].DateList[j].MorningList[n].Total
                  itemObj.Data4.SW.Id = this.tableData2[i].DateList[j].MorningList[n].Id
                }
                for (var n = 0; n < this.tableData2[i].DateList[j].AfterNoonList.length; n++) {
                  itemObj.Data4.XW.count += this.tableData2[i].DateList[j].AfterNoonList[n].Total
                  itemObj.Data4.XW.Id = this.tableData2[i].DateList[j].AfterNoonList[n].Id
                }
              }
              else if (this.tableData2[i].DateList[j].ScheduleDate === this.Date5 + " 0:00:00") {
                for (var n = 0; n < this.tableData2[i].DateList[j].MorningList.length; n++) {
                  itemObj.Data5.SW.count += this.tableData2[i].DateList[j].MorningList[n].Total
                  itemObj.Data5.SW.Id = this.tableData2[i].DateList[j].MorningList[n].Id
                }
                for (var n = 0; n < this.tableData2[i].DateList[j].AfterNoonList.length; n++) {
                  itemObj.Data5.XW.count += this.tableData2[i].DateList[j].AfterNoonList[n].Total
                  itemObj.Data5.XW.Id = this.tableData2[i].DateList[j].AfterNoonList[n].Id
                }
              }
              else if (this.tableData2[i].DateList[j].ScheduleDate === this.Date6 + " 0:00:00") {
                for (var n = 0; n < this.tableData2[i].DateList[j].MorningList.length; n++) {
                  itemObj.Data6.SW.count += this.tableData2[i].DateList[j].MorningList[n].Total
                  itemObj.Data6.SW.Id = this.tableData2[i].DateList[j].MorningList[n].Id
                }
                for (var n = 0; n < this.tableData2[i].DateList[j].AfterNoonList.length; n++) {
                  itemObj.Data6.XW.count += this.tableData2[i].DateList[j].AfterNoonList[n].Total
                  itemObj.Data6.XW.Id = this.tableData2[i].DateList[j].AfterNoonList[n].Id
                }
              }
              else if (this.tableData2[i].DateList[j].ScheduleDate === this.Date7 + " 0:00:00") {
                for (var n = 0; n < this.tableData2[i].DateList[j].MorningList.length; n++) {
                  itemObj.Data7.SW.count += this.tableData2[i].DateList[j].MorningList[n].Total
                  itemObj.Data7.SW.Id = this.tableData2[i].DateList[j].MorningList[n].Id
                }
                for (var n = 0; n < this.tableData2[i].DateList[j].AfterNoonList.length; n++) {
                  itemObj.Data7.XW.count += this.tableData2[i].DateList[j].AfterNoonList[n].Total
                  itemObj.Data7.XW.Id = this.tableData2[i].DateList[j].AfterNoonList[n].Id
                }
              }
            }

            this.tableData.push(itemObj);
          }
          console.log("数据整合完成后")
          console.log(this.tableData);
        })
        .catch(err => {
          console.log(err);
        });
    },
    //本周
    getBZTime () {
      // console.log("本周的开始时间");
      //本周的开始时间
      //                 console.log(this.getTime(0));
      // //本周的结束时间
      //                 console.log(this.getTime(-6));
      //                 var bdate = this.getTime(0)
      //                 var edate = this.getTime(-6)
      this.setDateInit(2);
      console.log("本周排班数据获取");
      this.getHZPBList(this.Date1, this.Date7)
    },
    getSZTime () {
      // console.log("上周的开始时间");
      //上周的开始时间
      //                 console.log(this.getTime(7));
      // //上周的结束时间
      //                 console.log(this.getTime(1));
      //                 var bdate = this.getTime(7)
      //                 var edate = this.getTime(1)
      this.setDateInit(1);
      console.log("上周排班数据获取");
      this.getHZPBList(this.Date1, this.Date7)
    },
    getXZTime () {
      // console.log("下周的开始时间");
      //上周的开始时间
      //                 console.log(this.getTime(-7));
      // //上周的结束时间
      //                 console.log(this.getTime(-14));
      //                 var bdate = this.getTime(-7)
      //                 var edate = this.getTime(-14)
      this.setDateInit(3);
      console.log("下周排班数据获取");
      this.getHZPBList(this.Date1, this.Date7)
    },
    getTime (n) {
      var now = new Date();
      var year = now.getFullYear();
      //因为月份是从0开始的,所以获取这个月的月份数要加1才行
      var month = now.getMonth() + 1;
      var date = now.getDate();
      var day = now.getDay();
      console.log(date);
      //判断是否为周日,如果不是的话,就让今天的day-1(例如星期二就是2-1)
      if (day !== 0) {
        n = n + (day - 1);
      } else {
        n = n + day;
      }
      if (day) {
        //这个判断是为了解决跨年的问题
        if (month > 1) {
          month = month;
        }
        //这个判断是为了解决跨年的问题,月份是从0开始的
        else {
          year = year - 1;
          month = 12;
        }
      }
      now.setDate(now.getDate() - n);
      year = now.getFullYear();
      month = now.getMonth() + 1;
      date = now.getDate();
      console.log(n);
      var s = year + "-" + (month < 10 ? ('0' + month) : month) + "-" + (date < 10 ? ('0' + date) : date) + "";
      return s;
    },

    setDateInit (type) {
      if (type == 1) {//上周
        this.Date1 = this.getTime(7);
        this.Date2 = this.getTime(6);
        this.Date3 = this.getTime(5);
        this.Date4 = this.getTime(4);
        this.Date5 = this.getTime(3);
        this.Date6 = this.getTime(2);
        this.Date7 = this.getTime(1);
      } else if (type == 2) {//本周
        this.Date1 = this.getTime(0);
        this.Date2 = this.getTime(-1);
        this.Date3 = this.getTime(-2);
        this.Date4 = this.getTime(-3);
        this.Date5 = this.getTime(-4);
        this.Date6 = this.getTime(-5);
        this.Date7 = this.getTime(-6);
      } else if (type == 3) {//下周
        this.Date1 = this.getTime(-7);
        this.Date2 = this.getTime(-8);
        this.Date3 = this.getTime(-9);
        this.Date4 = this.getTime(-10);
        this.Date5 = this.getTime(-11);
        this.Date6 = this.getTime(-12);
        this.Date7 = this.getTime(-13);
      }
    },
    /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&会诊医生排班结束&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/

    finishHZ (Status) {
      if (this.selectHZInfor == null) {
        this.$message({
          showClose: true,
          message: "请选择会诊数据！",
          type: "error"
        });
        return;
      }
      var params = {
        ConsultId: this.selectHZInfor.Id,
        Status: Status
      };
      //POST /api/ConsultBuss/ChangeConsultStatus
      this.$post("ConsultBuss/ChangeConsultStatus", params)
        .then(res => {
          console.log("结束会诊结果");
          console.log(res);
          if (res.code == 0) {
            this.getHZList();
            if (Status == 1) {
              this.showDialog('')
              this.getHZInfor(this.selectHZInfor.Id)
            }
          } else {
            this.$message({
              showClose: true,
              message: "申请会诊结束失败！",
              type: "error"
            });
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    handleClickPICItem (row) {
      console.log(row);
      this.imgSrcUrl = this.$getBaseIP() + row.FilePath;
      console.log("图片路径")
      console.log(this.imgSrcUrl)
      this.showDialog("PIC");
    },
    addHZVideo () {
      if (this.isZZ == 'OK') {
        this.finishHZ(2);
      }
      if (this.selectHZInfor == null) {
        this.$message({
          showClose: true,
          message: "请选择会诊明细！",
          type: "error"
        });
        return;
      }
      var params = {
        ConsultId: this.selectHZInfor.Id
      };
      this.$get("ConsultBuss/GetVideoUrl", params)
        .then(res => {
          console.log("会诊视频地址查询结果");
          console.log(res);
          // this.LoginInfor.UserName = "张珊"
          // var roomUrl = "https://121.43.170.162/webapp/conference/663800?name=" + this.LoginInfor.UserName + "&role=host"
          if (res.code == 0) {
            console.log("执行加入会议跳转")
            window.open(res.data, "_blank");
          }

        })
        .catch(err => {
          console.log(err);
        });


    },


    /***************分诊医生操作**************************/

    selectYSChange (val, column, event) {
      console.log("选中会诊医生数据");
      console.log(val)
      var Consult_Join = {
        Id: -1,
        ConsultId: this.huizhenObj.Consult.Id,
        DeptKind: 0,
        HospitalId: val.HospitalId,
        DeptId: this.selectDeptYS.Id,
        DoctorId: val.UserId,
        Doctor: val.UserName,
        UserName: val.UserName,
        Title: val.Title,
        Describe: val.Describe,
        ConRoomId: -1,
        isCanWrite: 0,
        IsMaster: 0,
        joinTime: "2020-01-14T02:09:31.447Z",
        JoinId: 0
      }

      this.huizhenObj.Consult_Joins.push(Consult_Join)
      this.addFZYS(Consult_Join)
      this.showDialogYS('')
    },

  },
  created () {
    if (this.$route.query.Token) {
      localStorage.setItem('Token', this.$route.query.Token)
    }
    this.getZZJGList();
    this.getHZList();
    this.setDateInit(2);
    this.getBZTime();
  }
};
</script>
<style lang="scss">
.BedinformationMZPB {
  .selectTime {
    .el-input__icon {
      height: 100%;
      width: 25px;
      display: none;
      text-align: center;
      -webkit-transition: all 0.3s;
      transition: all 0.3s;
      line-height: 40px;
    }

    .input {
      width: 90px !important;
      height: 28px !important;
    }
  }

  .column2 {
    width: 1126px;
    margin: 50px auto;
    background: #fff;
    border-radius: 5px;
    position: relative;
  }

  .div_P {
    .form-control {
      display: inline-block;
      width: 180px;
      height: 32px;
      padding: 5px 12px;
      font-size: 14px;
      line-height: 1.42857143;
      color: #555;
      background-color: #fff;
      background-image: none;
      border: 1px solid #ccc;
      border-radius: 4px;
      -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
      box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
      -webkit-transition: border-color ease-in-out 0.15s,
        -webkit-box-shadow ease-in-out 0.15s;
      transition: border-color ease-in-out 0.15s,
        -webkit-box-shadow ease-in-out 0.15s;
      transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
      transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s,
        -webkit-box-shadow ease-in-out 0.15s;
    }

    .form-group {
      height: 45px;
      margin: 0;
      line-height: 32px;
      padding: 6px 15px 0 15px;
    }
  }

  .fjtable {
    .el-table {
      font-size: 10px !important;
    }
  }

  .cardP {
    .text {
      font-size: 14px;
    }

    .el-card__header {
      padding: 18px 20px;
      border-bottom: 1px solid #ebeef5;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      background-color: azure;
    }

    .item {
      margin-bottom: 18px;
    }

    .clearfix:before,
    .clearfix:after {
      display: table;
      content: "";
    }

    .clearfix:after {
      clear: both;
    }

    .box-card {
      width: 100%;
    }
  }

  .cardC {
    .text {
      font-size: 14px;
    }

    .el-card__header {
      padding: 10px 20px;
      border-bottom: 1px solid #ebeef5;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      background-color: white;
    }

    .el-card__body {
      padding: 8px;
    }

    .item {
      margin-bottom: 18px;
    }

    .clearfix:before,
    .clearfix:after {
      display: table;
      content: "";
    }

    .clearfix:after {
      clear: both;
    }

    .box-card {
      width: 100%;
    }
  }

  .el-tree-node.is-current > .el-tree-node__content {
    color: #fff;
    background: #155a00 !important;
  }

  .dRightMain {
    padding: 18px;
  }

  .custom-tree-node {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding-right: 8px;
  }

  .el-table {
    font-size: 14px !important;
  }

  .el-table thead {
    color: #303133;
  }

  .dRightMain .Tb {
    position: absolute;
    top: 91px;
    left: 240px;
    right: 15px;
    bottom: 0;
    border: 1px solid #ddd;
  }
}

.InspectionCL22 {
  .selectTime {
    .el-input__icon {
      height: 100%;
      width: 25px;
      display: none;
      text-align: center;
      -webkit-transition: all 0.3s;
      transition: all 0.3s;
      line-height: 40px;
    }

    .input {
      width: 90px !important;
      height: 28px !important;
    }
  }

  .form-control {
    width: 106px !important;
  }

  .div_P {
    .form-control {
      display: inline-block;
      width: 180px;
      height: 32px;
      padding: 5px 12px;
      font-size: 14px;
      line-height: 1.42857143;
      color: #555;
      background-color: #fff;
      background-image: none;
      border: 1px solid #ccc;
      border-radius: 4px;
      -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
      box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
      -webkit-transition: border-color ease-in-out 0.15s,
        -webkit-box-shadow ease-in-out 0.15s;
      transition: border-color ease-in-out 0.15s,
        -webkit-box-shadow ease-in-out 0.15s;
      transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
      transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s,
        -webkit-box-shadow ease-in-out 0.15s;
    }

    .form-group {
      height: 45px;
      margin: 0;
      line-height: 32px;
      padding: 6px 15px 0 15px;
    }
  }

  .fjtable {
    .el-table {
      font-size: 10px !important;
    }
  }

  .cardP {
    .text {
      font-size: 14px;
    }

    .el-card__header {
      padding: 18px 20px;
      border-bottom: 1px solid #ebeef5;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      background-color: azure;
    }

    .item {
      margin-bottom: 18px;
    }

    .clearfix:before,
    .clearfix:after {
      display: table;
      content: "";
    }

    .clearfix:after {
      clear: both;
    }

    .box-card {
      width: 100%;
    }
  }

  .cardC {
    .text {
      font-size: 14px;
    }

    .el-card__header {
      padding: 10px 20px;
      border-bottom: 1px solid #ebeef5;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      background-color: white;
    }

    .el-card__body {
      padding: 8px;
    }

    .item {
      margin-bottom: 18px;
    }

    .clearfix:before,
    .clearfix:after {
      display: table;
      content: "";
    }

    .clearfix:after {
      clear: both;
    }

    .box-card {
      width: 100%;
    }
  }

  .el-tree-node.is-current > .el-tree-node__content {
    color: #fff;
    background: #155a00 !important;
  }

  .dRightMain {
    padding: 18px;
  }

  .custom-tree-node {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding-right: 8px;
  }

  .el-table {
    font-size: 14px !important;
  }

  .el-table thead {
    color: #303133;
  }

  .dRightMain .Tb {
    position: absolute;
    top: 91px;
    left: 240px;
    right: 15px;
    bottom: 0;
    border: 1px solid #ddd;
  }
}
</style>
